package com.fs.web.base.listener;

import cn.hutool.core.date.DateUtil;
import com.fs.web.base.service.CleanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author ACE
 * @desc 定时器，定时清除无效数据
 * @creationTime 2019-02-28 15:03
 * @projectName gps-root
 * @packageName com.fs.base.controller
 */
@Slf4j
@Component
@Configurable
@EnableScheduling
public class CleanListener {

    @Autowired
    private CleanService cleanService;

	/**
	 * 每天凌晨1点
	 */
    @Scheduled(cron = "0 0 2 * * ?")
    public void Statistics() {
    	try {
			cleanService.clean();
    		log.info(DateUtil.now()+"数据清理完成");
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
		}
	}
}
